import Vue from "vue";
import VueRouter from "vue-router";
import allRoutes from "./generateRoutes"
import staticRoutes from './staticRoutes'
import dynamicRoutes from './dynamicRoutes'
Vue.use(VueRouter);

const routes = [
    // {
    //     path: "/login",
    //     component: () =>   import(/* webpackChunkName: "log" */ "@/pages/login"),
    // },
    // {
    //     path: "/",
    //     component: () =>   import(/* webpackChunkName: "home" */ "@/pages/home"),
    //     redirect:'/welcome',
    //     children:[
    //         {
    //             name:'Welcome',
    //             path:'welcome',
    //             component: () =>   import(/* webpackChunkName: "welcome" */ "@/pages/home/Welcome"),

    //         },
    //         {
    //             name:'Studentproduct',
    //             path:'studentproduct',
    //             component: () =>   import(/* webpackChunkName: "studentproduct" */ "@/pages/home/StudentManager/StudentProduct"),

    //         },
    //         {
    //             name:'Studentprofile',
    //             path:'studentprofile',
    //             component: () =>   import(/* webpackChunkName: "studentprofile" */ "@/pages/home/StudentManager/StudentProfile"),

    //         },
    //         {
    //             name:'Studentdormitory',
    //             path:'studentdormitory',
    //             component: () =>   import(/* webpackChunkName: "studentdormitory" */ "@/pages/home/StudentManager/StudentDormitory"),

    //         },
    //         {
    //             name:'Attendance',
    //             path:'attendance',
    //             component: () =>   import(/* webpackChunkName: "attendance" */ "@/pages/home/Attendance"),

    //         },
    //         {
    //             name:'Users',
    //             path:'users',
    //             component: () =>   import(/* webpackChunkName: "users" */ "@/pages/home/Users"),

    //         },
    //         {
    //             name:'Statistics',
    //             path:'statistics',
    //             component: () =>   import(/* webpackChunkName: "users" */ "@/pages/home/Statistics"),

    //         },
    //         {
    //             name:'Mine',
    //             path:'mine',
    //             component: () =>   import(/* webpackChunkName: "mine" */ "@/pages/home/Mine"),

    //         },
    //         {
    //             name:'Charge',
    //             path:'charge',
    //             component: () =>   import(/* webpackChunkName: "mine" */ "@/pages/home/VipManager/Charge"),

    //         },
    //         {
    //             name:'Order',
    //             path:'order',
    //             component: () =>   import(/* webpackChunkName: "mine" */ "@/pages/home/VipManager/Order"),

    //         },

    //     ]
    // },
    // {
    //      path: "*",
    //      component: () =>   import(/* webpackChunkName: "log" */ "@/pages/page404"),
    // },
    {
        path: "/",
        redirect:'/welcome'
        // component: () =>   import(/* webpackChunkName: "log" */ "@/pages/login")
    },
    // ...allRoutes
    ...staticRoutes,
    dynamicRoutes
];

const router = new VueRouter({
  routes,
});



//#处理重复路由跳转报错
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}


export default router;
